package cn.edu.scau.chenmiaopeng.multipleton;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;

import javafx.event.ActionEvent;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
public class MyController {
    @FXML
    private TextField textfield;
    @FXML
    private Button button;
    @FXML
    private TextArea textarea;
    @FXML
    public void clickButton(ActionEvent e) { 
    	String marshalName = textfield.getText();
    	String createResult = Marshal.getInstance(marshalName);
        textarea.appendText(createResult+"\n");
        if(createResult.contains("@")) textfield.clear();
    }
    @FXML
    public void pressEnter(KeyEvent ke) {
    	if(ke.getEventType()==KeyEvent.KEY_RELEASED) {
    		if(ke.getCode().equals(KeyCode.ENTER)) {
        		String marshalName = textfield.getText();
            	String createResult = Marshal.getInstance(marshalName);
                textarea.appendText(createResult+"\n");       
                if(createResult.contains("@")) textfield.clear();
        	}
    	}
    }
}